package com.tchintech.pay.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.tchintech.pay.R;
import com.tchintech.pay.model.entity.Mymessage;

import java.util.List;

/**
 * Created by Administrator on 2017/7/11 0011.
 */

public class MessageAdapter extends BaseAdapter {
    private Context context;
    private List<Mymessage> list;

    public MessageAdapter(Context context, List<Mymessage> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View v, ViewGroup parent) {
        ViewHolder vh = null;
        if (v == null) {
            vh = new ViewHolder();
            v = LayoutInflater.from(context).inflate(R.layout.vp_message_item, null);
            vh.title = (TextView) v.findViewById(R.id.title);
            vh.time = (TextView) v.findViewById(R.id.time);
            v.setTag(vh);
        } else {
            vh= (ViewHolder) v.getTag();
        }
        final  Mymessage message=list.get(position);
        vh.title.setText(message.getTitle());
        vh.time.setText(message.getTime());
        return v;
    }


    class ViewHolder {
        TextView title, time;
    }


}
